package com.whfp.coky.api.response

import kotlin.math.ceil

/**
 *
 *
 * created by coky on 2022/3/8
 */
class ListBean<T> {
    /** 当前页码 */
    private val pageIndex: Int = 0

    /** 页大小 */
    private val pageSize: Int = 0

    /** 总数量 */
    private val dataCount: Int = 0

    /** 总页数 */
    private val totalPage: Int = 0

    /** 数据 */
    private val data: MutableList<T>? = null



    /**
     * 判断是否是最后一页
     */
    fun isLastPage(): Boolean {
        if (pageSize == 0) return true
        return pageIndex == totalPage||ceil((dataCount.toFloat() / pageSize.toFloat())) <= pageIndex
    }

    fun getTotalNumber(): Int {
        return dataCount
    }

    fun getPageIndex(): Int {
        return pageIndex
    }

    fun getPageSize(): Int {
        return pageSize
    }

    fun getData(): MutableList<T>? {
        return data
    }
}